<template>
	<z-paging ref="paging" v-model="golflist" @query="getgolf" :loading-more-enabled="false">
		<view class="d-p-l-30 d-p-r-30">
			<view class="d-flex d-p-t-20 d-p-b-20" v-for="(item, index) in golflist" :key="index">
				<u-avatar size="100rpx" :src="item.avatar"></u-avatar>
				<view class="d-flex-1 d-p-l-20">
					<view class="d-flex">
						<view class="d-flex-1">
							<view class="d-font-28">{{item.his_member_name || '' }}</view>
							<view class="d-font-26 d-be d-m-t-10">{{item.his_member_type || '' }}</view>
						</view>
						<view class="d-flex">
							<!-- <view class="d-m-r-38" @click="addFamily(item.member_id)"><u-image src="/static/e.png" width="28rpx" height="28rpx"></u-image></view> -->
							<view @click="(actionId = item.id), (show.del = true)"><u-image src="/static/d.png" width="28rpx" height="28rpx"></u-image></view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<d-mode :show="show.del" content="确认删除此家属吗？" @cancel="confirmDel" @confirm="show.del = false" cancel-text="确认删除" confirm-text="我再想想"></d-mode>
		<template slot="bottom">
			<view class="d-p-l-30 d-p-r-30 d-p-b-20 d-p-t-20">
				<u-button
					type="primary"
					shape="circle"
					:custom-style="{
						height: '80rpx',
						fontSize: '30rpx',
						background: '#59A0FF'
					}"
					@click="addFamily"
				>
					添加球友
				</u-button>
			</view>
		</template>
	</z-paging>
</template>

<script>
import { getFriend, bfDel } from '@/common/api';
export default {
	data() {
		return {
			golflist: [],
			show: {
				del: false
			},
			actionId: ''
		};
	},
	onShow() {
		try{
			this.$refs.paging.reload(false)
		}catch(e){
		}
	},
	methods: {
		getgolf(page, limit) {
			getFriend({ page, limit })
				.then(res => {
					let golflist = res.data.map(item => {
						item.show = false;
						return item;
					});
					this.$refs.paging.complete(golflist);
				})
				.catch(err => {
					this.$refs.paging.complete(false);
				});
		},
		
		
		confirmDel() {
			this.show.del = false;
			bfDel({
				id: this.actionId
			}).then(res => {
				uni.$u.toast('已删除');
				this.$refs.paging.reload(false);
			});
		},
		addFamily(id = '') {
			uni.$u.route({
				url: '/pages/mine/addgolfers',
				params: {
					id
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.d-be {
	color: #bebebe;
}
</style>
